package com.example.day09question;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.example.day09question.adapter.FvAdapter;
import com.example.day09question.fragment.OneFragment;
import com.example.day09question.fragment.TowFragment;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private ViewPager mVp;
    private TabLayout mTabMain;
    private ArrayList<Fragment> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {

        mVp = (ViewPager) findViewById(R.id.vp);

        mTabMain = (TabLayout) findViewById(R.id.tab_main);


        list = new ArrayList<>();

        list.add(new OneFragment());
        list.add(new TowFragment());
        FvAdapter fvAdapter = new FvAdapter(getSupportFragmentManager(), list);
        mVp.setAdapter(fvAdapter);
        mTabMain.setupWithViewPager(mVp);
        mTabMain.getTabAt(0).setText("首页");
        mTabMain.getTabAt(1).setText("类表");

    }
}
